package com.vibrationkeyboard.app.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.vibrationkeyboard.app.SensorStatus
import com.vibrationkeyboard.app.model.SensorData

class MainViewModel : ViewModel() {

    private val _sensorStatus = MutableLiveData<SensorStatus>(SensorStatus.STOPPED)
    val sensorStatus: LiveData<SensorStatus> = _sensorStatus

    private val _accelerometerData = MutableLiveData<SensorData>(SensorData(0f, 0f, 0f))
    val accelerometerData: LiveData<SensorData> = _accelerometerData

    private val _gyroscopeData = MutableLiveData<SensorData>(SensorData(0f, 0f, 0f))
    val gyroscopeData: LiveData<SensorData> = _gyroscopeData

    private val _recognitionResult = MutableLiveData<String>("等待识别...")
    val recognitionResult: LiveData<String> = _recognitionResult

    private val _isProcessing = MutableLiveData<Boolean>(false)
    val isProcessing: LiveData<Boolean> = _isProcessing

    fun setSensorStatus(status: SensorStatus) {
        _sensorStatus.value = status
    }

    fun updateAccelerometerData(data: SensorData) {
        _accelerometerData.value = data
    }

    fun updateGyroscopeData(data: SensorData) {
        _gyroscopeData.value = data
    }

    fun updateRecognitionResult(result: String) {
        _recognitionResult.value = result
    }

    fun setProcessing(processing: Boolean) {
        _isProcessing.value = processing
    }

    fun clearData() {
        _accelerometerData.value = SensorData(0f, 0f, 0f)
        _gyroscopeData.value = SensorData(0f, 0f, 0f)
        _recognitionResult.value = "等待识别..."
    }
} 